<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>添加角色</title>
    <link href="/css/style.css" rel="stylesheet" type="text/css" />
    <script src="/js/vue3.js"></script>
    <script src="/js/axios.min.js"></script>
</head>

<body>
    <div class="place">
        <span>位置：</span>
        <ul class="placeul">
            <li><a href="#">权限管理</a></li>
            <li><a href="#">添加角色</a></li>
        </ul>
    </div>
    <div class="formbody" id="box">
        <!-- 工具栏 -->
        <div class="tools">
            <ul class="toolbar">
                <li v-on:click="goback"><span><img src="/images/t04.png" /></span>返回</li>
            </ul>
        </div>
        <form id="uploadForm">
            <div class="formtitle"><span>添加角色</span></div>
            <ul class="forminfo">
                <li><label>角色名</label><input v-model="rolename" type="text" class="dfinput" /></li>
                <li><label>权限注释</label><input v-model="description" type="text" class="dfinput" /></li>
            </ul>
            <input type="button" class="scbtn" v-on:click="addRoleButton" value="添加">
            &nbsp;
            <input type="reset" class="scbtn" value="重置">
        </form>
    </div>
</body>

<script>
    var obj = {
        data () {
            return {
                rolename: '',
                description: '',
            }
        },
        methods: {
            addRoleButton () {
                axios({
                    method: 'post',
                    url: '/blog/admin/role',
                    data: {
                        rolename: this.rolename,
                        description: this.description
                    },
                }).then(function (result) {
                    window.alert(result.data.msg);
                    if (result.data.code == 0) {
                        setTimeout(function () {
                            window.location.reload();
                        }, 500);
                    }
                });
            },
            goback () {
                window.history.back();
            }
        }
    }
    var vm = Vue.createApp(obj).mount("#box")
</script>

</html>